package org.duiduo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import tk.mybatis.spring.annotation.MapperScan;

/**
 * 启动类
 *
 * @author 夜泷noga
 */
@EnableEurekaClient // 开启服务
@EnableFeignClients(basePackages = { "org.duiduo.**.facade" }) // 开启feign调用
@EnableAsync // 启用@Async
@EnableTransactionManagement // 启动事务
@EnableCaching // 开启缓存
@SpringBootApplication
@MapperScan({ "org.duiduo.repository" }) // import tk.mybatis.spring.annotation.MapperScan; 注意导入的包 必须是tk的
@EnableAspectJAutoProxy
@PropertySource(value = "classpath:config.properties", encoding = "UTF-8")
public class ServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(ServiceApplication.class, args);
    }

    // 读取配置文件内容
    @Value("${account.username}")
    private String username;

    @Value("${account.phone}")
    private String phone;

    @Value("${account.price}")
    private Double price;

    @Bean
    public void init() {
        System.out.println(username);
        System.out.println(phone);
        System.out.println(price);
    }

}
